package seatiger.tomcat.coyote.http11;

import seatiger.tomcat.coyote.InputBuffer;
import seatiger.tomcat.coyote.Request;
import seatiger.tomcat.util.buf.ByteChunk;

import java.io.IOException;

/**
 * 字节读取的过滤器
 */
public interface InputFilter extends InputBuffer {

    /**
     * 读取bytes放入字节快中
     * @param byteChunk
     * @param request
     * @return
     * @throws IOException
     */
    @Override
    int doRead(ByteChunk byteChunk, Request request) throws IOException;

    /**
     * 关联的coyote request
     * @param request
     */
    void setRequest(Request request);

    /**
     * 重置
     */
    void recycle();

    /**
     * 下一个执行的过滤器
     * @param inputBuffer
     */
    void setBuffer(InputBuffer inputBuffer);

    /**
     * 消耗本次请求中没有读取的数据
     * @return
     * @throws IOException
     */
    long end() throws IOException;
}
